cmake_minimum_required(VERSION 3.5 FATAL_ERROR) # CMake version check
project(recipe_06_foreach VERSION 0.1 LANGUAGES CXX) # Create project "recipe_06_foreach" with version 0.1 and two languages C and C++ enabled

add_library(geometry STATIC 
            include/geometryCircle.hpp 
            include/geometrySquare.hpp 
            include/geometryPolygon.hpp
            include/geometryRhombus.hpp
            src/geometryCircle.cpp 
            src/geometrySquare.cpp
            src/geometryPolygon.cpp
            src/geometryRhombus.cpp)

target_compile_options(geometry PRIVATE -O3)

list(APPEND sources_with_lower_optimization 
        src/geometryCircle.cpp
        src/geometryRhombus.cpp)
message(STATUS "Setting source properties using IN LISTS syntax:")
foreach(_source IN LISTS sources_with_lower_optimization)
    set_source_files_properties(${_source} PROPERTIES COMPILE_FLAGS "-O2")
    message(STATUS "Appending -O2 flag for ${_source}")
endforeach()

message(STATUS "Querying sources properties using plain syntax:")
foreach(_source ${sources_with_lower_optimization})
    get_source_file_property(_flags ${_source} COMPILE_FLAGS)
    message(STATUS "Source ${_source} has the following extra COMPILE_FLAGS: ${_flags}")
endforeach()

add_executable(compute-areas helloWorld.cpp src/message.cpp) # 添加message.cpp
target_link_libraries(compute-areas geometry)